#ifndef TOPICDETAILDIALOG_H
#define TOPICDETAILDIALOG_H

#include "dialogbase.h"
#include "ui_topicdetaildialog.h"
#include "admindbmanager.h"
#include "tableschema.h"

class TopicDetailDialog : public DialogBase<Ui_topicDetailDialog>
{
    Q_OBJECT

public:
    TopicDetailDialog( QWidget * parent );
    TopicDetailDialog( QWidget * parent, const Topic & topic );
    ~TopicDetailDialog();
    const Topic & topic() const;

private:
    void updateDialog();
    void enableSavePushButton();
    void init();
    void enableTopicCategory( TopicCategory::Enum topicCategory, bool enable );
    bool getQuestion( const qint64 & id, Question & question ) const;
    void add();
    void update( int row, const qint64 & id );
    void remove( int row, const qint64 & id );

private slots:
    void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
    void onTopicNameLineEditTextChanged( const QString & text );
    void onBibleCheckBoxToStateChanged( bool checked );
    void onTeoCheckBoxStateChanged( bool checked );
    void onScientificCheckBoxStateChanged( bool checked );
    void onHumanCheckBoxStateChanged( bool checked );
    void onAdd();
    void onUpdate();
    void onRemove();
    void onQuestionTableViewContextMenu( const QPoint & point, const QModelIndex & modelIndex );
    void onQuestionTableViewDoubleClicked( const QModelIndex & modelIndex );

private:
    QuestionTableManager m_questionTableManager;
    Topic m_topicOld;
    Topic m_topic;
};

#endif
